﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AgencyEntityLib.BaseEntity;
using System.Web.UI.WebControls;
using Ecopsy.DataTier;
using Ecopsy.DataTier.SqlLibrary;


namespace AgencyEntityLib.BaseEntity
{
    /// <summary>
    /// Визуальное предтавление в гриднике
    /// </summary>
    public class grdClient
    {
        private Client _Client;
        public Client Client { get { return _Client; } }

        public grdClient(Client cl) { _Client = cl; }
        public virtual string Status
        {
            get
            {                
                return _Client.GetTxtClientStatus();
            }
        }
        /// <summary>
        /// Контакты строчкой без адреса
        /// </summary>
        public virtual string ShortContactList
        {
            get
            {
                string [] s= {GlobalConstants.Contact_Phone,GlobalConstants.Contact_Email, GlobalConstants.Contact_Url};                        
                return _Client.ContactList.GetContactsAsString("|",s);                
            }
        }
        public virtual string Curator 
        {
            get { 
                    Employeer  cr= _Client.GetCurator();
                    if (cr == null) return string.Empty;
                    return cr.ShortName;
                }
        }
        public virtual string Categoria
        {
            get
            {
                return _Client.GetTxtClientCategoria();
            }
        }
        
        public virtual string Name { get { return _Client.Name; } }
        public virtual string Phones { get { return _Client.Phones; } }

    }
         

    public static class ClientExt
    {
        public static string GetTxtClientCategoria(this Client _Client)
        {
            return TreeDictionaryContext.GetPropertyVal(_Client.Ctegoria);
        }

        public static string GetTxtClientStatus(this Client _Client)
        {
            return TreeDictionaryContext.GetPropertyVal(_Client.StatusValue);
        }

        //public static ContactFaceList GetContactFaces(this Client _Client)
        //{
        //    ws_Face w = new ws_Face();
        //    ContactFaceList.sqlLoadStatment where = new ContactFaceList.sqlLoadStatment();
        //    vPropertyOfList.ParamListItem   F= new vPropertyOfList.ParamListItem (){Param ="ClientID", Value =_Client.ID};
        //    where.ParamValueList.Add(F);
        //    where.ParamValueList_SearchOption=Ecopsy.DataTier.SqlLibrary.vPropertyOfList.Options.ParamValue ;
        //    ContactFaceList l = w.GetContactFaceList (where);
        //    return l;
        //}


        //public static string GetTxtClientCategoria(this Client  _Client)
        //{
        //    return TreeDictionaryContext.GetPropertyVal (_Client.Ctegoria);
        //}
        
        //public static string GetTxtClientStatus(this Client _Client)
        //{
        //    return TreeDictionaryContext.GetPropertyVal(_Client.StatusValue);
        //}
        
        //public static Employeer   GetCurator(this Client _Client)
        //{
        //    try
        //    {
        //        if (string.Empty == _Client.CuratorID) return null;
        //        ws_Face _ws = new ws_Face();
        //        return _ws.GetEmpl(_Client.CuratorID);
        //    }
        //    catch
        //    {
        //        return null;
        //    }

        //}        
        
        

    }
}